package com.yanqu.road.server.cmd.wingroom;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.wingroom.WingRoomModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.wingroom.WingRoomMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_WING_ROOM_CAL_EVENT_RED_DOT_NOTIFY_FROM_CROSS, desc = "跨服来通知重新计算呼朋唤友事件红点")
public class UserCalVisitRedDotFromCross implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {

        WingRoomProto.CrossCalEventRedDotNotifyMsg reqMsg = WingRoomProto.CrossCalEventRedDotNotifyMsg.parseFrom(packet.getBytes());

        for (Long userId : reqMsg.getUserIdList()) {
            GamePlayer player = GamePlayerMgr.getOnlinePlayer(userId);
            if(player == null){
                continue;
            }
            WingRoomMgr.getLogger().debug("-----------玩家计算事件红点：{}", player.getUserId());
            player.getModule(WingRoomModule.class).calVisitRedDot(WingRoomProto.UserWingRoomRedDotSync.newBuilder());
        }

    }
}
